<?php
class ModelMarketingMarketing extends Model {

	public function getAvilableMarketing() {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "marketing WHERE status = '1' order by date_added DESC LIMIT 0,1");

		return $query->row;
	}
	
	public function getMarketings($start = 0, $limit = 20) {
	
	    if ($start < 0) {
	        $start = 0;
	    }
	     
	    if ($limit < 1) {
	        $limit = 20;
	    }
	     
	
	    $sql = "SELECT * FROM " . DB_PREFIX . "marketing WHERE status='1' ORDER BY date_added DESC";
	
	
	    $sql .= " LIMIT " . (int)$start . "," . (int)$limit;
	
	    $query = $this->db->query($sql);
	
	    return $query->rows;
	}
	
	public function getTotalMarketings() {
	    $sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "marketing WHERE status='1'";
	
	    $query = $this->db->query($sql);
	
	    return $query->row['total'];
	}

}
